Public Class Users
    Inherits DABase

    Public Function GetUserListByUsertype(ByVal userType As Byte, ByVal startRecord As Integer, ByVal maxRecords As Integer) As DataSet
        Dim ds As New DataSet
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[GetUserListByUsertype]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add("@USER_TYPE", userType)

        Dim da As New SqlDataAdapter(sqlCommand)

        da.Fill(ds, startRecord, maxRecords, "ORDER_SELECTS")
        Return ds
    End Function

    Protected Overrides Function getDeleteCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[UserDeleteCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_US_ID_PK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "US_ID_PK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_BAR_CODE", System.Data.SqlDbType.VarChar, 7, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "BAR_CODE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_COUNTRY", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "COUNTRY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CUSTOMER_CODE", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CUSTOMER_CODE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_EMAIL", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "EMAIL", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_IS_ADMIN", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IS_ADMIN", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_IS_ENABLED", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IS_ENABLED", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_LOGIN_NAME", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "LOGIN_NAME", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NAME", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "NAME", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PASSWORD", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PASSWORD", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_USER_TYPE", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "USER_TYPE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SORT_REFERENCE1", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SORT_REFERENCE1", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SORT_REFERENCE2", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SORT_REFERENCE2", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_DOWNLOADABLE_CSV", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DOWNLOADABLE_CSV", System.Data.DataRowVersion.Original, Nothing))

        Return sqlCommand
    End Function

    Protected Overrides Function getInsertCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[UserInsertCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NAME", System.Data.SqlDbType.VarChar, 50, "NAME"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LOGIN_NAME", System.Data.SqlDbType.VarChar, 20, "LOGIN_NAME"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PASSWORD", System.Data.SqlDbType.VarChar, 50, "PASSWORD"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@EMAIL", System.Data.SqlDbType.VarChar, 50, "EMAIL"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@USER_TYPE", System.Data.SqlDbType.TinyInt, 1, "USER_TYPE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@COUNTRY", System.Data.SqlDbType.VarChar, 50, "COUNTRY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CUSTOMER_CODE", System.Data.SqlDbType.VarChar, 20, "CUSTOMER_CODE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@BAR_CODE", System.Data.SqlDbType.VarChar, 7, "BAR_CODE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IS_ADMIN", System.Data.SqlDbType.Bit, 1, "IS_ADMIN"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IS_ENABLED", System.Data.SqlDbType.Bit, 1, "IS_ENABLED"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_DATE", System.Data.SqlDbType.DateTime, 8, "CREATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_BY", System.Data.SqlDbType.Int, 4, "CREATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, "UPDATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_BY", System.Data.SqlDbType.Int, 4, "UPDATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SORT_REFERENCE1", System.Data.SqlDbType.VarChar, 20, "SORT_REFERENCE1"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SORT_REFERENCE2", System.Data.SqlDbType.VarChar, 20, "SORT_REFERENCE2"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DOWNLOADABLE_CSV", System.Data.SqlDbType.Bit, 1, "DOWNLOADABLE_CSV"))

        Return sqlCommand
    End Function

    Protected Overrides Function getSelectCommand(ByVal keys() As Object) As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[UserSelectCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))

        Dim param As SqlParameter
        param = New SqlClient.SqlParameter("@US_ID_PK", System.Data.SqlDbType.Int, 4, "US_ID_PK")
        param.Value = keys(0)
        sqlCommand.Parameters.Add(param)

        Return sqlCommand
    End Function

    Protected Overrides Function getUpdateCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[UserUpdateCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NAME", System.Data.SqlDbType.VarChar, 50, "NAME"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LOGIN_NAME", System.Data.SqlDbType.VarChar, 20, "LOGIN_NAME"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PASSWORD", System.Data.SqlDbType.VarChar, 50, "PASSWORD"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@EMAIL", System.Data.SqlDbType.VarChar, 50, "EMAIL"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@USER_TYPE", System.Data.SqlDbType.TinyInt, 1, "USER_TYPE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@COUNTRY", System.Data.SqlDbType.VarChar, 50, "COUNTRY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CUSTOMER_CODE", System.Data.SqlDbType.VarChar, 20, "CUSTOMER_CODE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@BAR_CODE", System.Data.SqlDbType.VarChar, 7, "BAR_CODE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IS_ADMIN", System.Data.SqlDbType.Bit, 1, "IS_ADMIN"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IS_ENABLED", System.Data.SqlDbType.Bit, 1, "IS_ENABLED"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_DATE", System.Data.SqlDbType.DateTime, 8, "CREATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_BY", System.Data.SqlDbType.Int, 4, "CREATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, "UPDATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_BY", System.Data.SqlDbType.Int, 4, "UPDATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SORT_REFERENCE1", System.Data.SqlDbType.VarChar, 20, "SORT_REFERENCE1"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SORT_REFERENCE2", System.Data.SqlDbType.VarChar, 20, "SORT_REFERENCE2"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DOWNLOADABLE_CSV", System.Data.SqlDbType.Bit, 1, "DOWNLOADABLE_CSV"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_US_ID_PK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "US_ID_PK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_BAR_CODE", System.Data.SqlDbType.VarChar, 7, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "BAR_CODE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_COUNTRY", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "COUNTRY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CUSTOMER_CODE", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CUSTOMER_CODE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_EMAIL", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "EMAIL", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_IS_ADMIN", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IS_ADMIN", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_IS_ENABLED", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IS_ENABLED", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_LOGIN_NAME", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "LOGIN_NAME", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NAME", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "NAME", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PASSWORD", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PASSWORD", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_USER_TYPE", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "USER_TYPE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SORT_REFERENCE1", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SORT_REFERENCE1", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SORT_REFERENCE2", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SORT_REFERENCE2", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_DOWNLOADABLE_CSV", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DOWNLOADABLE_CSV", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@US_ID_PK", System.Data.SqlDbType.Int, 4, "US_ID_PK"))

        Return sqlCommand
    End Function
End Class
